import 'package:flutter/material.dart';
import 'package:hz_actionsheet/hz_actionsheet.dart';
import 'package:hz_actionsheet/hz_bottomsheet_action.dart';
import 'package:hz_dialog/hz_dialog.dart';
import 'package:hz_dialog/hz_dialog_action.dart';
import 'package:hzcloud_flt/common/hz_loading/hz_loading_dialog.dart';
import 'package:hzcloud_flt/common/hz_network/hz_network.dart';
import 'package:hzcloud_flt/common/hz_network_test.dart';
import 'package:hzcloud_flt/models/banner.dart';


class HZTextPage extends StatelessWidget {
  final List _list = ['ActionSheet', 'Dialog','loading','toast','success','fail','network'];

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: ListView.builder(
        itemBuilder: (context, index) {
          String title = _list[index];
          return Ink(
            color: Colors.primaries[index % Colors.primaries.length],
            child: InkWell(
              onTap: () {
                if (index == 0) {
                  List<HZBottomSheetAction> actions = [
                    HZBottomSheetAction(Text('选项1'), (_) {}),
                    HZBottomSheetAction(Text('选项2'), (_) {}),
                    HZBottomSheetAction(Text('选项3'), (_) {}),
                  ];
                  showHZActionSheet(
                    context: context,
                    actions: actions,
                    cancelAction: HZBottomSheetAction(Text('取消'), (_) {}),
                  );
                } else if (index == 1) {
                  List<HZDialogAction> actions = [
                    HZDialogAction(Text('取消'), () {}),
                    HZDialogAction(
                      Text(
                        '确定',
                        style: TextStyle(color: Colors.blue),
                      ),
                      () {},
                    ),
                  ];
                  showHZDialog(
                    context: context,
                    content: Text(
                        '测试内容测试\\容测试内容测试容测试内容测试会计师的容测试内容测试会计师的容测试内容测试会计师的容测试内容测试会计师的容测试内容测试会计师的容测试内容测试会计师的容测试内容测试会计师的会计师的'),
                    title: Text('标题来了'),
                    actions: actions,
                  );
                } else if (index == 2) {
                  HZLoadingDialog.showLoading(msg: '加载中...',dismissOnTap:true);
                } else if (index == 3) {
                  HZLoadingDialog.showToast('加载中。。。');
                } else if (index == 4) {
                  HZLoadingDialog.showSuccess('操作成功');
                } else if (index == 5) {
                  HZLoadingDialog.showError('提交失败');
                } else if (index == 6) {
                  // HZLoadingDialog.showLoading(msg: '加载中...',dismissOnTap:true);
                  // var data ={
                  //   "ParkID":"R3711012020041111111",
                  //   "code":"main",
                  //   "q":"code"
                  // };
                  // HZNetworkConfig config = HZNetworkConfig(HZNetworkFetchMethod.get, '/p/sps/api/v1/public/banners',data: data);
                  // HZNetwork.request(config).then((response){
                  //   HZLoadingDialog.dismiss();
                  //   HZLoadingDialog.showSuccess('操作成功');
                  //   BannerInfo banner = BannerInfo.fromJson(response.data);
                  //   print(banner.items.first.address);
                  // }).catchError((error){
                  //   HZLoadingDialog.dismiss();
                  //   HZLoadingDialog.showError('${error.toString()}');
                  // });
                  Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){
                    return new HZNetworkTest();
                  }));
                }
              },
              child: Container(
                height: 45,
                alignment: Alignment.center,
                child: Text(
                  title,
                  style: TextStyle(fontSize: 17, color: Colors.white),
                ),
              ),
            ),
          );
        },
        itemCount: _list.length,
      ),
    );
  }
}
